<!DOCTYPE html>
<body>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>

<input>

<script>
test(() => {
  assert_own_property(window, 'eventSender');
  var element = document.querySelector('input');
  element.value = '';
  element.focus();
  eventSender.keyDown('c');
  assert_equals(element.selectionStart, 1, 'Before any type changes');
  element.type = 'password';
  assert_equals(element.selectionStart, 1, 'After changing to password');
  element.type = 'button';
  assert_equals(element.selectionStart, null, 'After changing to button');
  element.type = 'text';
  assert_equals(element.selectionStart, 0, 'After changing back to text');
}, 'selectionStart/selectionEnd should be kept after input type changes.');
</script>
</body>
